import time

from selenium import webdriver

# 设置请求头
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.57'
}

# 设置代理
proxy = 'https://dps.kdlapi.com/api/getdps/?secret_id=o8dwnxxu6fy8d25y7mvw&num=1&signature=n86gw540grw65csznaz351noortcx83q&pt=1&sep=1'

# 创建Chrome WebDriver，并设置请求头和代理
driver = webdriver.Chrome()
# 加载网址
driver.get("https://www.shanghairanking.cn/rankings/bcur/2021")
driver.maximize_window()
time.sleep(4)
driver.find_element_by_xpath(
    "//li[@class=' ant-pagination-next']/a[@class='ant-pagination-item-link']").click()
while True:
    driver.find_element_by_xpath("//li[@class=' ant-pagination-next']/a[@class='ant-pagination-item-link']").click()
    time.sleep(3)
    name = driver.find_element_by_xpath(
        "//div[@id='content']/div[@id='content-box']/div[@class='rk-table-box']/table[@class='rk-table']").text
    print(name)
    time.sleep(3)

